<?php
namespace BP\En;
class EntityNoName extends EntityNo {
	public function getName () 
	{
		return $this->GetValStringByKey(EntityNoNameAttr::$Name);
	}
	public function setName ($value) // [String value]
	{
		$this->SetValByKey(EntityNoNameAttr::$Name, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($_No) // [String _No]
	{
		$me = new self();
		parent::constructor__String($_No);
		return $me;
	}
	protected function beforeInsert () 
	{
		if (($this->getNo()->trim()->length() == 0))
		{
			if ($this->getEnMap()->getIsAutoGenerNo())
			{
				$this->setNo($this->getGenerNewNo());
			}
			else
			{
				throw new \RuntimeException((((((("@没有给[" . $this->getEnDesc()) . " ") . $this) . " , ") . $this->getName()) . "]设置主键,能执行插�?."));
			}
		}
		if (($this->getEnMap()->getIsAllowRepeatName() ==  FALSE ))
		{
			if (($this->getPKCount() == 1))
			{
				if (($this->ExitsValueNum("Name", $this->getName()) >= 1))
				{
					throw new \RuntimeException((((((("@插入失败[" . $this->getEnMap()->getEnDesc()) . "] 编号[") . $this->getNo()) . "]名称[") . $this->getName()) . "]重复."));
				}
			}
		}
		return parent->beforeInsert();
	}
	protected function beforeUpdate () 
	{
		if (($this->getEnMap()->getIsAllowRepeatName() ==  FALSE ))
		{
			if (($this->getPKCount() == 1))
			{
				if (($this->ExitsValueNum("Name", $this->getName()) >= 2))
				{
					throw new \RuntimeException((((((("@更新失败[" . $this->getEnMap()->getEnDesc()) . "] 编号[") . $this->getNo()) . "]名称[") . $this->getName()) . "]重复."));
				}
			}
		}
		return parent->beforeUpdate();
	}
}
?>
